package cn.le.springAnnotationCustomize;

import cn.le.springAnnotationCustomize.model.Form;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.validation.BindException;
import org.springframework.validation.Validator;


/**
 * Created by admin on 2017/3/30.
 */
public class Test {


    /**
     * 实现spring自动装载自定义注解,并自动完成注解功能
     */
    public static void main(String[] args) {

        ApplicationContext app = new ClassPathXmlApplicationContext("spring-springAnotationCustmoize.xml");
        Validator customerValidatorFactory = (Validator) app.getBean("customerValidatorFactory");

        Form form = new Form("2015 11 11");
        BindException errors = new BindException(form, "target");
        customerValidatorFactory.validate(form,errors);
        System.out.println(errors.getFieldErrors());

    }

}
